package health.lm.com.shop.utils;

import android.app.Activity;
import android.support.v4.app.Fragment;

import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.entity.LocalMedia;

import java.util.ArrayList;
import java.util.List;

import health.lm.com.shop.R;

/**
 * Created by Android Studio .
 * Project：shangjiyin com.lm.sjy.util
 * Date：2019/5/21 16:31
 * Introduce：图片预览
 */
public class PicturePreview {
    public static void preview(Activity activity, List<String> strings) {
        List<LocalMedia> localMedia = new ArrayList<>();
        for (int i = 0; i < strings.size(); i++) {
            LocalMedia media = new LocalMedia();
            media.position = i;
            media.setCompressPath(strings.get(i));
            media.setPath(strings.get(i));
            media.setCutPath(strings.get(i));
            localMedia.add(media);
        }
        PictureSelector.create(activity).themeStyle(R.style.picture_theme_style)
                .openExternalPreview(0, localMedia);
    }

    public static void preview(Fragment activity, List<String> strings) {
        List<LocalMedia> localMedia = new ArrayList<>();
        for (int i = 0; i < strings.size(); i++) {
            LocalMedia media = new LocalMedia();
            media.position = i;
            media.setCompressPath(strings.get(i));
            media.setPath(strings.get(i));
            media.setCutPath(strings.get(i));
            localMedia.add(media);
        }
        PictureSelector.create(activity).themeStyle(R.style.picture_theme_style)
                .openExternalPreview(0, localMedia);
    }
}
